package io.github.yotta.common.web.context;

import java.util.Map;

/**
 * @author yotta
 * @date 2022/11/8 14:40
 */
public class HeaderContext {

    private HeaderContext() {
    }

    private static final ThreadLocal<Map<String, String>> HEADERS = new ThreadLocal<>();

    public static void setHeaders(Map<String, String> headers) {
        HEADERS.set(headers);
    }


    public static Map<String, String> getHeaders() {
        return HEADERS.get();
    }

    public static String getHeader(String name) {
        return HEADERS.get() == null ? null : HEADERS.get().get(name);
    }

    public static void clearHeaders() {
        HEADERS.remove();
    }


}
